#include"Logger.hpp"

#include <unistd.h>

int main()
{
         //EnableConsoleLogStrategy();
    EnableFileLogStrategy();

    // RAII风格的日志构建和输出刷新的过程
    LOG(Loglevel::ERROR) << "hello world" << ", 3.14 " << 123;
    LOG(Loglevel::WARNING) << "hello world" << ", 3.14 " << 123;
    LOG(Loglevel::ERROR) << "hello world" << ", 3.14 " << 123;
    LOG(Loglevel::ERROR) << "hello world" << ", 3.14 " << 123;



    std::string test = "hello world, hello log";
    std::unique_ptr<LogStrategy> logger_ptr =std::make_unique<FileLogStrategy>();
    //我即将拥有一个指向 LogStrategy 类型对象的独占所有权智能指针
    //相当于：
    //FileLogStrategy* raw_ptr = new FileLogStrategy();      // 传统 C++ 手动 new
    //std::unique_ptr<LogStrategy> logger_ptr(raw_ptr);     // 用 unique_ptr 接管
     // // 测试策略1：显示器写入
    // std::unique_ptr<LogStrategy> logger_ptr = std::make_unique<ConsoleLogStrategy>();
    // // logger_ptr->SyncLog(test);
    // logger_ptr->SyncLog(test);
    // logger_ptr->SyncLog(test);
    // logger_ptr->SyncLog(test);
    // logger_ptr->SyncLog(test);

    logger_ptr->SyncLog(GetCurrentTime());
    sleep(1);
    logger_ptr->SyncLog(GetCurrentTime());
    sleep(1);
    logger_ptr->SyncLog(GetCurrentTime());
    sleep(1);
    logger_ptr->SyncLog(GetCurrentTime());
    sleep(1);
    logger_ptr->SyncLog(GetCurrentTime());
    sleep(1);


}